class Solution(object):
    def maximumGood(self, statements):
        n = len(statements)
        def judge(val):
            for i in range(n):
                if (val >> i) & 1:
                    for j in range(n):
                        if statements[i][j] == 1:
                            if (val >> j) & 1 == 0:
                                return False
                        if statements[i][j] == 0:
                            if (val >> j) & 1 == 1:
                                return False
            return True
        max_ans = 0
        for val in range(2 ** n):
            if judge(val):
                max_ans = max(val.bit_count(), max_ans)
        return max_ans

data = Solution()
# statements = [[2,1,2],[1,2,2],[2,0,2]]
statements = [[2,2,2,2],[1,2,1,0],[0,2,2,2],[0,0,0,2]]
print(data.maximumGood(statements))